package com.example.administrator.xmut.kcb;

import java.sql.Date;
import java.util.ArrayList;
import java.util.Calendar;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.xmut.R;
import com.example.administrator.xmut.http.CourseBean;

public class ListViewAdapter extends BaseAdapter {
	private Context context;
	private ArrayList<CourseBean> data;
	public ListViewAdapter(Context context, ArrayList<CourseBean> data) {
		this.context = context;
		this.data = data;
	}

	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = View.inflate(context, R.layout.listview_item_layout,
					null);
			holder = new ViewHolder();
			holder.CouseName = (TextView) convertView
					.findViewById(R.id.CourseName);
			holder.CourseAddress = (TextView) convertView
					.findViewById(R.id.CourseAddress);
			holder.CourseWeek = (TextView) convertView
					.findViewById(R.id.CourseWeek);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		CourseBean course = data.get(position);
		holder.CouseName.setText(course.getCourse_name());
		holder.CourseAddress.setText(course.getCourse_address());
		holder.CourseWeek.setText(course.getCourse_week());
		return convertView;
	}

	class ViewHolder {
		TextView CouseName;
		TextView CourseAddress;
		TextView CourseWeek;
	}



}
